package com.xtkj.superclub_information.service.impl;

import com.xtkj.superclub_entity.entity.travel.Travel;
import com.xtkj.superclub_entity.entity.travel.TravelComment;
import com.xtkj.superclub_entity.entity.travel.TravelCommentReply;
import com.xtkj.superclub_information.dao.TravelCommentDao;
import com.xtkj.superclub_information.dao.TravelCommentReplyDao;
import com.xtkj.superclub_information.dao.TravelDao;
import com.xtkj.superclub_information.service.ITravelReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author lizheqi
 * @create 2020-01-04-9:38
 */
@Service
public class TravelReplyServiceImpl implements ITravelReplyService {
    @Autowired
    private TravelCommentReplyDao travelCommentReplyDao;
    @Autowired
    private TravelCommentDao travelCommentDao;
    @Autowired
    private TravelDao travelDao;
    /**
     * 游记评论回复
     * @param travelCommentReply
     */
    @Override
    public void reply(TravelCommentReply travelCommentReply) {
        travelCommentReply.setCreatedtm(new Date()).setCreatedtm(new Date());
        //对游记评论回复之后获取该游记评论
        travelCommentReplyDao.insert(travelCommentReply);
        TravelComment travelComment = travelCommentDao.selectById(travelCommentReply.getTravelCommentId());
        //更新该游记评论
        travelComment.setUpdatedtm(new Date());
        travelCommentDao.updateById(travelComment);
        //获取该游记评论对应的游记
        Travel travel = travelDao.selectById(travelComment.getTravelId());
        travel.setUpdatedtm(new Date());
        //更新该游记
        travelDao.updateById(travel);
    }
}
